package logic

import (
	"context"
	"zg1/user-profile/models/mysql"

	"zg1/user-profile/userRpc/internal/svc"
	"zg1/user-profile/userRpc/userRpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type UserShowLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewUserShowLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserShowLogic {
	return &UserShowLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *UserShowLogic) UserShow(in *userRpc.UserShowRequest) (*userRpc.UserShowResponse, error) {
	// todo: add your logic here and delete this line

	user := mysql.UserZy{}
	mysql.DB.Debug().Where("id=?", in.UserId).Find(&user)

	return &userRpc.UserShowResponse{
		UserId: int64(user.ID),
		Image:  user.Image,
		Name:   user.Name,
		Info:   user.Info,
	}, nil
}
